package cn.tedu.kaifanlav1.user.controller;


import cn.tedu.kaifanlav1.base.response.JsonResult;
import cn.tedu.kaifanlav1.user.pojo.dto.FoodParam;
import cn.tedu.kaifanlav1.user.pojo.dto.UserQuery;
import cn.tedu.kaifanlav1.user.pojo.dto.UserSaveParam;
import cn.tedu.kaifanlav1.user.pojo.vo.UserVO;
import cn.tedu.kaifanlav1.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j

@RestController
@RequestMapping("/v1/menu")
public class UserController {
    @Autowired
    UserService userservice;//注意:注入的是接口!

    @GetMapping("select")
    public JsonResult selectUser(UserQuery userQuery){
        log.debug("查询用户:userQuery={}",userQuery);
        List<UserVO> list = userservice.selectUser(userQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult saveUser(@RequestBody UserSaveParam UserSaveParam ){
        log.debug("保存用户:userVO={}",UserSaveParam );
        userservice.saveUser(UserSaveParam );
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult delectFood(@PathVariable Long id){
        log.debug("删除菜品:FoodId={}",id);
        userservice.delectFood(id);
        return JsonResult.ok();
    }
    @PostMapping("insert/{id}")
    public JsonResult updateFood(@PathVariable Long id){
        log.debug("添加菜品:FoodId={}",id);
        userservice.insertFood(id);
        return JsonResult.ok();
    }
}
